import presetWeapp from 'unocss-preset-weapp';
import { extractorAttributify, transformerClass } from 'unocss-preset-weapp/transformer';

const { presetWeappAttributify, transformerAttributify } = extractorAttributify();

export default {
    rules: [
        [/^flex-(\d+)$/, ([, d]) => ({ flex: `${d} ${d} 0%` })],
        [
            /^text-overflow-ellipsis$/,
            () => ({
                'white-space': 'nowrap',
                overflow: 'hidden',
                'text-overflow': 'ellipsis'
            })
        ],
        [
            /^btn-shadow$/,
            () => ({
                'box-shadow': 'rgba(1, 35, 171, 0.2) 0px 20px 25px -5px, rgba(1, 35, 171, 0.08) 0px 10px 10px -5px'
            })
        ]
    ],
    presets: [
        // https://github.com/MellowCo/unocss-preset-weapp
        presetWeapp({
            whRpx: true
        }),
        // attributify autocomplete
        presetWeappAttributify()
    ],

    transformers: [
        // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
        transformerAttributify(),

        // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
        transformerClass()
    ]
};
